package com.headwind.logistics.operation.service.impl;


import com.headwind.logistics.common.pojo.FetchMoney;

import com.headwind.logistics.operation.dto.FetchMoneyPaymentTransportUserDto;
import com.headwind.logistics.operation.mapper.WithdrawMoneyDaoInter;
import com.headwind.logistics.operation.pojo.WithdrawMoney;
import com.headwind.logistics.operation.service.inter.WithdrawMoneyBizInter;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 周鑫
 * @Date 2020/7/16 16:41
 * @Version 1.0
 * @DESCRIPTION 业务逻辑层实现类
 */
@Service
public class WithdrawMoneyBizImpl implements WithdrawMoneyBizInter {


    @Resource
    WithdrawMoneyDaoInter withdrawMoneyDaoInter;

    /**
     * 查询所有和分页功能
     * @return dto集合
     */
    @Override
    public List<FetchMoneyPaymentTransportUserDto> queryWithdrawMoneyBizInter(@Param("page") Integer page, @Param("rows") Integer rows) {

        if (page != null){
            page = (page-1)*rows;
        }
        return  withdrawMoneyDaoInter.queryWithdrawMoneyDaoInter(page,rows);

    }



    /**
     * 根据id修改余额提现审核表状态
     * @param checkMoneyId 主键id
     * @return int
     */
    @Override
    public int updateWithdrawMoneyBizInter( int checkMoneyId){

        return withdrawMoneyDaoInter.updateWithdrawMoneyDaoInter(checkMoneyId);
    }

    /**
     * 根据id修改余额提现审核表状态
     * @param checkMoneyId 主键id
     * @return int
     */
    @Override
    public int updateWithdrawMoneyBizInterTow(int checkMoneyId) {
        return withdrawMoneyDaoInter.updateWithdrawMoneyDaoInterTow(checkMoneyId);
    }

    /**
     * 根据id修改余额提现审核表状态
     * @param checkMoneyId 主键id
     * @return int
     */
    @Override
    public int updateWithdrawMoneyBizInterThree(int checkMoneyId) {
        return withdrawMoneyDaoInter.updateWithdrawMoneyDaoInterThree(checkMoneyId);
    }

    /**
     * 根据id修改余额提现审核表状态
     * @param checkMoneyId 主键id
     * @return
     */
    @Override
    public int updateWithdrawMoneyBizInterFour(int checkMoneyId) {
        return withdrawMoneyDaoInter.updateWithdrawMoneyDaoInterFour(checkMoneyId);
    }

    /**
     * 根据id修改原因和状态
     * @param withdrawMoney 模型层
     * @return int
     */
    @Override
    public int updateWithdrawMassageBizInter(WithdrawMoney withdrawMoney) {
        return withdrawMoneyDaoInter.updateWithdrawMassageDaoInter(withdrawMoney);
    }

    /**
     * 根据id修改状态和原因
     * @param withdrawMoney 模型层
     * @return int
     */
    public int updateWithdrawMassageTowBizInter(WithdrawMoney withdrawMoney){

        return withdrawMoneyDaoInter.updateWithdrawMassageTowDaoInter(withdrawMoney);
    }

    /**
     * 根据id修改提现金额
     * @param checkMoneyId 主键id
     * @param fetchPrice 提现金额
     * @return int
     */
    @Override
    public int updateWithdrawFetchPriceBizInter(Integer checkMoneyId, Double fetchPrice,Double money) {
        money = money-fetchPrice;
        System.out.println(money+"+===========================================================");
        return withdrawMoneyDaoInter.updateWithdrawFetchPriceDaoInter(checkMoneyId,fetchPrice,money);
    }
}
